home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / text / misc / MSWordView_src.lha / mswordview / laolareplace.c < prev    next >
C/C++ Source or Header  |  1998-12-02  |  2KB  |  66 lines

  1. /*
  2. The interface to myOLEdecode now has
  3.   int OLEdecode(char *filename, FILE **mainfd, FILE **tablefd0, FILE 
  4. **tablefd1,FILE **data)    
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include "config.h"
  11. #include "mswordview.h"
  12. #include "oledecod.h"
  13.  
  14. extern FILE*erroroutput;
  15.  
  16. pps_entry *stream_tree;
  17.  
  18. void myfreeOLEtree(void)
  19.     {
  20.     /* need to free all the allocated memory */
  21.     freeOLEtree (stream_tree);
  22.     }
  23.  
  24.  
  25. int myOLEdecode(char *filename, FILE **mainfd, FILE **tablefd0, FILE **tablefd1,FILE **data)
  26.     {
  27.     int result;
  28.     U32 root_stream;
  29.     U32 stream;
  30.  
  31.     result = OLEdecode (filename, &stream_tree, &root_stream, 1);
  32.     if (result == 0)
  33.         {
  34.         for (stream = stream_tree[root_stream].dir; stream != 0xffffffff; stream = stream_tree[stream].next)
  35.             {
  36.             if (stream_tree[stream].type != 1 && stream_tree[stream].level == 1)
  37.                 {
  38.                 if (!(strcmp(stream_tree[stream].name,"WordDocument")))
  39.                     {
  40.                     *mainfd = fopen(stream_tree[stream].filename,"rb");
  41.                     }
  42.                 else if (!(strcmp(stream_tree[stream].name,"1Table")))
  43.                     {
  44.                     *tablefd1 = fopen(stream_tree[stream].filename,"rb");
  45.                     }
  46.                 else if (!(strcmp(stream_tree[stream].name,"0Table")))
  47.                     {
  48.                     *tablefd0 = fopen(stream_tree[stream].filename,"rb");
  49.                     }
  50.                 else if (!(strcmp(stream_tree[stream].name,"Data")))
  51.                     {
  52.                     *data = fopen(stream_tree[stream].filename,"rb");
  53.                     }
  54.                 }
  55.             }
  56.         }
  57.     switch(result)
  58.         {
  59.         case 5:
  60.             fprintf(erroroutput,"OLE file appears to be corrupt, unable to extract streams\n");
  61.             break;
  62.         }
  63.  
  64.     return(result);
  65.     }
  66.